/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
int main_1031_1()
{
    int weights[]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
    char ZM[]="10X98765432";
    char ID[19]={0};
    vector<string> vs;
    int N,sum=0;
    scanf("%d",&N);
    for (int i=0;i<N ;++i )
    {
        scanf("%s",ID);
        sum=0;
        for (int j=0;j<17 ;++j )
        {
            sum+=weights[j]*(ID[j]-'0');
        }
        if (ZM[sum%11]!=ID[17])
        {
            vs.push_back(string(ID));
        }
    }
    if (vs.size()==0)
    {
        printf("All passed");
    }
    else
    {
        for(auto i:vs)
        {
            printf("%s\n",i.c_str());
        }
    }
	return 0;
}
